<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'da.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<meta http-equiv="content-type" content="text/html;charset=utf-8">

<link rel="stylesheet" href="js/easyui/demo/demo.css" type="text/css"></link>
<link rel="stylesheet" href="js/easyui/themes/icon.css" type="text/css"></link>
<link rel="stylesheet" href="js/easyui/themes/default/easyui.css"
	type="text/css"></link>
<script type="text/javascript" src="js/easyui/jquery-1.6.min.js"></script>
<script type="text/javascript" src="js/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="script/common.js"></script>
<script type="text/javascript" src="js/easyui/themes/easyui-lang-zh_CN.js"></script>
<link href="css/style.css" rel="stylesheet" type="text/css">
<style type="text/css">

</style>
<script type="text/javascript">
	/**
	 * 根据制定页面跳转
	 */
	function reload() {
		var offset = document.getElementById("offset").value;
		var idx = (offset == null) ? 0 : parseInt(offset) - 1;
			
		window.location = 'regSuinfindSuinRegist?offset=' + idx;
	}
	
	/**
	 * 根据条件查询
	 */
	function query() {
		var realName = $("#realName").val();
		var suinCode = $("#suinCode").val();
		var createTimeSt = $("#createTimeSt").datebox('getValue');
		var createTimeEd = $("#createTimeEd").datebox('getValue');
		window.location = 'regSuinfindSuinRegist?realName='+realName+'&suinCode='+suinCode
					+'&createTimeSt='+createTimeSt+'&createTimeEd='+createTimeEd;
		
	}
	
	/**
	* 翻到给定偏移量的页面
	*/
	function turnPage(offset){
		var realName = $("#realName").val();
		var suinCode = $("#suinCode").val();
		var createTimeSt = $("#createTimeSt").datebox('getValue');
		var createTimeEd = $("#createTimeEd").datebox('getValue');
		window.location = 'regSuinfindSuinRegist?realName='+realName+'&suinCode='+suinCode
					+'&createTimeSt='+createTimeSt+'&createTimeEd='+createTimeEd+'&offset=' + offset;			
	}
	
	
	/**
	 * 确认审核
	 * @returns {Boolean}
	 */
	function sureDelMaterial(realName,id) {
		var msg = "确定要审核 ["+realName+"] 供应商吗？";
		if (confirm(msg) == true) {
			$.ajax({
				type:'POST',
				url:'regSuinupSuinInfo',
				data:{
					'id':id
				},
				dataType : 'json',
				success : function(data){
					if(data){
						$.messager.show({
							msg : '<div style="width:100%"><div style="line-height:50px;text-align:center;">审核供应商成功！</div></div>',
							timeout : 800,
							showSpeed : 200,
							showType : 'show',
							style : {
								right : '',
								top : '',
								bottom : ''
							}
						});
						window.location =  'regSuinfindSuinRegist.action';
					}
				}
			});
			return true;
		} else {
			return false;
		}
	}
	
	
	
	/**
	 * 状态格式化
	 */
	function statusFormater(val, row) {
		val = val.trim();
		switch (val) {
		case '0':
			val = "未审核";
			break;
		case '1':
			val = "审核通过";
			break;
		}

		return val;
	}
</script>
</head>

<body>
	
	<div style="margin:20px 20px 0px 20px; width:85%;">
		<div id="options" class="toolbar">
			<div style="width: 100%;float: none;">
				<div style="float: left;">
					<a href="regSuinfindSuinRegist" class="easyui-linkbutton"
						data-options="iconCls:'icon-reload'" style="margin-right: 10px;">刷新</a>
				</div>
				<div style="float: left; margin-bottom: 10px;">
					<input class="easyui-textbox" type="text" id="realName" prompt="供应商名称" value="${realName}" data-options="height:26">
					<input class="easyui-textbox" type="text" id="suinCode" prompt="营业执照注册编码" value="${suinCode}" data-options="height:26">
					<input class="easyui-datebox" type="text" id="createTimeSt" prompt="生成时间" value="${createTimeSt}" data-options="height:26">
					<span>-</span>
					<input class="easyui-datebox" type="text" id="createTimeEd" prompt="生成时间" value="${createTimeEd}" data-options="height:26">
				</div>
				<div style=" float: left;">
					<input class="easyui-linkbutton"
						type="button" id="query" style="margin-left: 15px;"
						onclick="query()" value="查询 ">
				</div>
			</div>
		</div>
		<div style="width:100%; float: left;" id = "show">
			<table class="easyui-datagrid" style="width:100%;" singleSelect="true">
				<thead>
					<tr>
						<th data-options="field:'code'" width="">序号</th>
						<th data-options="field:'suinName'">供应商登录名称</th>
						<th data-options="field:'realName'">供应商名称</th>
						<th data-options="field:'suinCode'">营业执照注册编码</th>
						<th data-options="field:'address'">供应商地址</th>
						<th data-options="field:'phone'">联系电话</th>
						<th data-options="field:'email'">联系邮件</th>
						<th data-options="field:'state'"formatter="statusFormater">状态</th>
						<th data-options="field:'createTime'">生成时间</th>
						<th data-options="field:'操作'">操作</th>
					</tr>
				</thead>
				
				<c:choose>
					<c:when test="">
						<tr style="text-align: center;">
							<td colspan="11">
								<span style="color: grey;"></span>
							</td>
						</tr>
					</c:when>
					<c:otherwise>
						<c:forEach items="${listsregiter}" var="SuinRegister" varStatus="i">
							<tr>
								
								<td>
									<c:out value="${i.index+1+offset*10 }" />
								</td>
								<td>
									<c:out value="${SuinRegister.suinName}" />
								</td>
								
								<td>
									<c:out value="${SuinRegister.realName}"/>
								</td>
								
								<td>
									<c:out value="${SuinRegister.suinCode}" />
								</td>
								
								<td>
									<c:out value="${SuinRegister.address}" />
								</td>
								
								<td>
									<c:out value="${SuinRegister.phone}" />
								</td>
								<td>
									<c:out value="${SuinRegister.email}" />
								</td>
								<td>
									<c:out value="${SuinRegister.state}" />
								</td>
								<td>
									<fmt:setLocale value="zh_cn" /> 
									<a href="" title="${SuinRegister.createTime}"><font><fmt:formatDate value="${SuinRegister.createTime}" type="date" dateStyle="long" /></font></a>
								</td>
								<td>
									<a onclick="javascript:return sureDelMaterial('${SuinRegister.realName}','${SuinRegister.id}')" style="text-decoration: underline;">审核</a>
								</td>
								
							</tr>
						</c:forEach>
					</c:otherwise>
				</c:choose>
				
			</table>
			<div class="pager" id="pagebar">
				共<b id="ttCount">${totalcount }</b>条记录 转到&nbsp;<input value="${offset+1}" size="2" id="offset" class="easyui-textbox" />&nbsp;页/<b id="ttPage">${totalpage }</b>页
				<button class="easyui-linkbutton jump-btn" width="20" onclick="reload()">跳转</button>
				<a onclick="turnPage(0)">&lt;&lt; 第一页</a> <a
					onclick="turnPage(${offset-1})">&lt; 上一页</a> <a
					onclick="turnPage(${offset+1})">下一页 &gt;</a> <a
					onclick="turnPage(${totalpage-1})">最后一页 &gt;&gt;</a>
			</div>
		</div>
	</div>

</body>
</html>
